﻿using Coldairarrow.Business.Base_AutoReplys;
using Coldairarrow.Entity.Base_AutoReplys;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.Base_AutoReplys
{
    [Route("/Base_AutoReplys/[controller]/[action]")]
    public class Base_ARQuestionController : BaseApiController
    {
        #region DI

        public Base_ARQuestionController(IBase_ARQuestionBusiness base_ARQuestionBus)
        {
            _base_ARQuestionBus = base_ARQuestionBus;
        }

        IBase_ARQuestionBusiness _base_ARQuestionBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<Base_ARQuestion>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _base_ARQuestionBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<Base_ARQuestion> GetTheData(IdInputDTO input)
        {
            return await _base_ARQuestionBus.GetTheDataAsync(input.Id);
        }

        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(Base_ARQuestion data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _base_ARQuestionBus.AddDataAsync(data);
            }
            else
            {
                await _base_ARQuestionBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _base_ARQuestionBus.DeleteDataAsync(ids);
        }

        [HttpPost]
        public async Task ChangeState(List<string> ids)
        {
            await _base_ARQuestionBus.ChangeStates(ids);
        }
        #endregion
    }
}